from django.shortcuts import render

# Create your views here.
from django.views import View
from employee.models import *

class MentView(View):
    def get(self,request):
        employees = Employee.objects.all()
        return render(request, 'admin-department.html', {'employees': employees})

class SettingView(View):
    def get(self,request):
        ments = Ment.objects.all()
        return render(request, 'ad-setting.html', {'ments': ments})

class AddView(View):
    def get(self,request):
        return render(request, 'ad-add.html')
    def post(self,request):

        ment = request.POST.get('ment')
        emp = Ment(ment_name=ment)
        emp.save()
        ments = Ment.objects.all()
        employees = Employee.objects.all()
        return render(request, 'ad-setting.html', {'employees': employees})
class DellView(View):
    def get(self,request):
        id =request.GET.get('id')
        delemp = Ment.objects.filter(id=id)
        delemp.delete()
        ments = Ment.objects.all()
        return render(request, 'ad-setting.html', {'ments': ments})

class ShowView(View):
    def get(self,request):
        id = request.GET.get('id')
        emp = Employee.objects.get(s_id=id)
        return render(request, 'ad-setting.html', {'employees': emp})

class MohuView(View):
    def get(self,request):
        condition = request.GET.get('condition')
        mohu = request.GET.get('mohu')
        emps = Employee.objects.get(ment_id=id)
        if condition==emps:
            if mohu ==emps:
                employees = Employee.objects.all()
                return render(request, 'ad-setting.html', {"employees": employees})
            else:
                employees = Employee.objects.filter(ment_id=mohu)
                return render(request, 'ad-setting.html', {"employees": employees})


